package com.sitc.street_lab_2013;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class LocationsListviewAdapter extends ArrayAdapter<String> {
	private final Activity context;
	private final Object[] values;

	public LocationsListviewAdapter(Activity context, Object[] objects) {
		super(context, R.layout.locations_listview_item);
		this.context = context;
		this.values = objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = context.getLayoutInflater();
		View rowView = inflater.inflate(R.layout.locations_listview_item, null);

		TextView title = (TextView) rowView.findViewById(R.id.firstline);
		TextView desc = (TextView) rowView.findViewById(R.id.secondLine);
		ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
		
		SitcLoc loc = (SitcLoc) values[position];

		title.setText(loc.getLocName());
		title.setSelected(true);
		desc.setText(loc.getLocDesc());
		imageView.setImageResource(R.drawable.ic_launcher);



		return rowView;
	}
	
	@Override
    public int getCount() {
        // TODO Auto-generated method stub
        return values.length;
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return 1;
    }
}
